package org.budo.weixin.work.api;

import org.budo.weixin.api.WeixinMediaUploadResult;
import org.budo.weixin.work.TaskCardMessage;
import org.budo.weixin.work.WorkWeixinMessage;
import org.budo.weixin.work.api.entity.ApprovalDetail;
import org.budo.weixin.work.api.entity.ChatInfo;
import org.budo.weixin.work.api.entity.Department;
import org.budo.weixin.work.api.entity.TemplateDetail;
import org.budo.weixin.work.api.entity.User;
import org.budo.weixin.work.api.entity.WorkWeixinToken;
import org.budo.weixin.work.message.WorkWeixinMessageDomain;

import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author li
 * @version 1 (2015年10月12日 下午2:21:25)
 * @since Java7
 */
public interface WorkWeixinApi {
    /**
     * 获取打卡数据
     */
    void getCheckinData();

    /**
     * 获取打卡规则
     */
    void getCheckinOption();

    /**
     * 获取Token
     */
    WorkWeixinToken getToken(String corpId, String corpSecret);

    /**
     * 获取Token
     */
    String getWeixinToken(String corpId, String corpSecret);

    /**
     * 部门列表
     */
    List<Department> getDepartmentList(String departmentId);

    /**
     * 部门成员列表
     */
    List<User> getUserInfoListByDepartmentId(Integer departmentId, Boolean fetchChild);

    /**
     * Code 换 OpenId
     */
    String getOpenIdByCode(String accessToken, String code);

    /**
     * Code 换 UserId
     */
    String getUserIdByCode(String accessToken, String code);

    /**
     * 发消息
     */
    String sendMessage(WorkWeixinMessage workWeixinMessage);

    /**
     * 发消息
     */
    String sendMessage(WorkWeixinMessageDomain workWeixinMessage);

    /**
     * 发卡片消息
     */
    String sendTaskCardMessage(TaskCardMessage taskCardMessage);

    /**
     * 提交菜单
     */
    String createMenu(String menusToString, String agentId);

    /**
     * 查询菜单
     */
    String getMenu(String agentId);

    /**
     * 删除菜单
     */
    String deleteMenu(String agentId);

    /**
     * 查询用户信息
     */
    Map<String, Object> getUserInfo(String userId);

    /**
     * 查询媒体资源
     */
    String getMedia(String mediaId);

    /**
     * 二维码
     */
    String getWorkWeixinQrCode();

    Map<String, Object> getSnsToken(String appId, String appSecret, String code);

    /**
     * 上传媒体资源
     */
    WeixinMediaUploadResult uploadMedia(String type, Object media);

    /**
     * 获取审批模板详情
     */
    TemplateDetail getTemplateDetail(String templateId);

    /**
     * 提交审批申请
     */
    String applyEvent(String creatorUserId, String templateId, String summary, Map<String, Object> templateContent);

    /**
     * 提交审批申请
     */
    String applyEvent(String creatorUserId, String templateId, List<String> summaryList, Map<String, Object> templateContent);

    /**
     * 批量获取审批单号
     */
    List<String> getApprovalInfo(Date startTime, Date endTime, Map<String, Object> filters, Integer cursor, Integer size);

    /**
     * 获取审批申请详情
     */
    ApprovalDetail getApprovalDetail(String spNo);

    String verifyUrl(String signature, String timestamp, String nonce, String echostr);

    String decryptMessage(String signature, String timestamp, String nonce, String requestBody);

    ApprovalDetail parseApprovalWebhook(String input);

    String uploadFileByUrl(URL url);

    String webhookSendText(String url, String text);

    String uploadMediaReturnId(String type, Object media);

    String getTicket(String access_token,String type);

    String getJsapiTicket(String access_token,String type);

    String getJsapiTicketNoType(String access_token);

    String getAccessToken(String corpid,String corpsecret);

    String getUserIdOrOpenIdByCode(String accessToken, String code);

    /**
     * 创建群
     */
    String createAppChat(String access_token, String name, String owner, List<String> userlist);

    /**
     * 修改群 或修改成员
     */
    String updateAppChat(String access_token, String chatid, String name, String owner, List<String> add_user_list, List<String> del_user_list);

    /**
     * 获取群信息
     */
    ChatInfo getAppChat(String access_token, String chatid);

    /**
     * 应用推送消息
     * @param access_token
     * @param chatid
     * @param content
     * @return
     */
    String appChatSend(String access_token, String chatid, String content);

    String convertToOpenid(String access_token, String userid);

    String convertToUserid(String access_token, String openid);

    /**
     * 创建成员 https://work.weixin.qq.com/api/doc/90000/90135/90195
     */
    String createUser(String userid, String name, List<Integer> department, String mobile);

    /**
     * 删除用户
     * @param userid
     * @return
     */
    String deleteUser(String userid);

    /**
     * 更新部门
     * @param userid
     * @param department
     * @return
     */
    String updateDepartment(String userid, List<Integer> department);
}
